package web.login.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import web.login.dao.LoginDao;
import web.login.entity.Login;

@Repository(value="loginDao")
@Transactional
public class LoginDaoImpl implements LoginDao{

	private SessionFactory sessionFactory;
	
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public void saveLogin(Login login)
	{
		sessionFactory.getCurrentSession().saveOrUpdate(login);
	}
	
	@SuppressWarnings("unchecked")
	public List<Login> getAllLogin() {
		return (List<Login>) sessionFactory.getCurrentSession().createCriteria(Login.class).list();
	}
	
}
